﻿using System.Windows.Data;
using SABnzbdNET.Commands;
using SABnzbdNET.Model;

namespace SABnzbdNET.Converters
{
    public class CommandParameterConverter : IMultiValueConverter
    {
        public object Convert(object[] values, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            switch (((string)parameter).ToLower())
            {
                case "'processing'":
                    {
                        var param = new ProcessingCommandParameter();

                        foreach (var obj in values)
                        {
                            if (obj is string)
                                param.Processing = obj as string;

                            if (obj is Job)
                                param.Job = obj as Job;
                        }
                        return param;
                    }
                case "'priority'":
                    {
                        var param = new PriorityCommandParameter();

                        foreach (var obj in values)
                        {
                            if (obj is string)
                                param.Priority = obj as string;

                            if (obj is Job)
                                param.Job = obj as Job;
                        }
                        return param;
                    }
            }
            return null;
        }

        public object[] ConvertBack(object value, System.Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }
    }
}
